package com.heima.wemedia.controller.v1;

import com.heima.model.article.dtos.ArticleCommentConfigDto;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.article.dtos.ArticleInfoDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentManageDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.pojos.ApCommentLike;
import com.heima.wemedia.service.WmCommentManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/comment/manage")
public class WmCommentManageController {

    @Autowired
    private WmCommentManageService wmCommentManageService;

    /**
     * 评论列表查询
     * @param dto
     * @return
     */
    @PostMapping("/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody ArticleCommentDto dto){
        log.info("评论列表查询:"+dto);
        return wmCommentManageService.findAllComments(dto);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult deleteComment(@PathVariable String commentId){
        log.info("删除评论:"+commentId);
        return wmCommentManageService.deleteComment(commentId);
    }

    /**
     * 删除评论回复
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult deleteCommentRepay(@PathVariable String commentRepayId){
        log.info("删除评论回复: "+commentRepayId);
        return wmCommentManageService.deleteCommentRepay(commentRepayId);
    }
    @PostMapping("/comment_repay")
    public ResponseResult repayComment(@RequestBody CommentRepaySaveDto dto){
        return wmCommentManageService.repayComment(dto);
    }

    @PostMapping("/list")
    public ResponseResult listComment(@RequestBody CommentManageDto dto){
        return wmCommentManageService.listComment(dto);
    }

    /**
     * 作者点赞评论
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult likeComment(@RequestBody CommentLikeDto dto){
        log.info("作者点赞");
        return wmCommentManageService.likeComment(dto);
    }

    /**
     * 打开或关闭评论
     * @param dto
     * @return
     */
    @PostMapping("/update_comment_status")
    public ResponseResult setCommentStasus(@RequestBody ArticleCommentConfigDto dto){
        return wmCommentManageService.setCommentStasus(dto);
    }
}
